Fix #1448: fix: 添加包含偏好信息的记忆后,使用搜索接口POST /product/search无法检索到任何记忆#1983
Open
Memtensor-AI wants to merge 1 commit into
Open
Fix #1448: fix: 添加包含偏好信息的记忆后,使用搜索接口POST /product/search无法检索到任何记忆#1983Memtensor-AI wants to merge 1 commit into
Memtensor-AI wants to merge 1 commit into
Conversation
`/product/search` (fine mode) cannot find memories added through the fast pipeline because `tree_text_memory._graph_recall` filters Neo4j candidates by `n.key IN parsed_goal.keys` and tag overlap >= 2. Fast-mode add stores the raw chat-formatted text as `key` and `["mode:fast"]` as `tags`, while fine-mode search asks the LLM for high-level semantic keys/tags, so the strict candidate set comes back empty and the structured branch silently drops the memory. Extract a lenient `_node_matches_parsed_goal` post-filter that also accepts substring matches and a single tag overlap, and add `_fallback_candidates_by_substring` which uses `graph_store.get_all_memory_items` (bounded to 50) to recover fast-mode memories. Restricted to WorkingMemory / LongTermMemory / UserMemory / OuterMemory so PreferenceMemory and other scopes keep their dedicated retrievers. Regression tests cover the reporter's exact scenario, substring post-filter, single-tag overlap, and graceful empty return.
5 tasks
Collaborator
Author
✅ Automated Test Results: PASSEDNo applicable test scope for the changed files — automated tests skipped. Changed paths do not map to any configured scope (env.yaml source_mapping). Manual review recommended. Branch: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #1448 —
/product/search(fine mode) returning empty results for memories added through the fast pipeline. Root cause:tree_text_memory._graph_recallfiltered Neo4j candidates byn.key IN parsed_goal.keysand tag overlap ≥ 2, but fast-mode add stores the raw chat-formatted text askeyand only["mode:fast"]astags, while fine-mode search asks the LLM for high-level semantic keys/tags, so the strict candidate set comes back empty and the structured branch silently dropped the memory.The fix extracts a lenient
_node_matches_parsed_goalpost-filter that accepts substring key matches and a single tag overlap, and adds_fallback_candidates_by_substringwhich uses the existinggraph_store.get_all_memory_itemsAPI (bounded to 50 candidates per call) to substring-matchparsed_goal.keysagainst storedkey + memorytext whenever the strict candidate set is empty. The fallback is scoped to WorkingMemory / LongTermMemory / UserMemory / OuterMemory so PreferenceMemory and other specialized scopes keep their dedicated retrievers. Wrapped in try/except so unexpected backends silently degrade to the previous behavior. No API, schema, or migration impact.Tests: 4 new regression tests in
tests/memories/textual/test_tree_retriever.pycover the reporter's exact scenario, substring post-filter, single-tag overlap, and graceful empty return. All 62 tests undertests/memories/textual/pass after the fix;ruff checkandruff formatboth clean. The 6 unrelated failures undertests/mem_reader/andtests/api/are pre-existing on thedev-20260624-v2.0.22baseline (verified by stashing the fix and re-running).Related Issue (Required): Fixes #1448
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Automated tests are pending.
Checklist
@MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller please review this PR.
Reviewer Checklist